<template>
  <div class="uni-steps">
    <div :class="[direction==='column'?'uni-steps__column':'uni-steps__row']">

      <div :class="[direction==='column'?'uni-steps__column-container':'uni-steps__row-container']">
        <div :class="[direction==='column'?'uni-steps__column-line-item':'uni-steps__row-line-item']" v-for="(item,index) in options" :key="index">
          <div :class="[direction==='column'?'uni-steps__column-line':'uni-steps__row-line',direction==='column'?'uni-steps__column-line--before':'uni-steps__row-line--before']" :style="{backgroundColor:index<=active&&index!==0?activeColor:index===0?'transparent':deactiveColor}"></div>

          <div :class="[direction==='column'?'uni-steps__column-circle':'uni-steps__row-circle']" :style="{backgroundColor:index<active?activeColor:deactiveColor}">{{index+1}}</div>
          <div :class="[direction==='column'?'uni-steps__column-line':'uni-steps__row-line',direction==='column'?'uni-steps__column-line--after':'uni-steps__row-line--after']" :style="{backgroundColor:index<active&&index!==options.length-1?activeColor:index===options.length-1?'transparent':deactiveColor}"></div>
        </div>
      </div>
      <div style="margin-top:10px;" :class="[direction==='column'?'uni-steps__column-text-container':'uni-steps__row-text-container']">
        <div v-for="(item,index) in options" :key="index" :class="[direction==='column'?'uni-steps__column-text':'uni-steps__row-text']">
          <span :class="[direction==='column'?'uni-steps__column-title':'uni-steps__row-title']">{{item.title}}</span>
          <span :class="[direction==='column'?'uni-steps__column-desc':'uni-steps__row-desc']">{{item.desc}}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    direction: {
      // 排列方向 row column
      type: String,
      default: 'row'
    },
    activeColor: {
      // 激活状态颜色
      type: String,
      default: '#1aad19'
    },
    deactiveColor: {
      // 未激活状态颜色
      type: String,
      default: '#F8B43A'
    },
    active: {
      // 当前步骤
      type: Number,
      default: 0
    },
    options: {
      type: Array,
      default () {
        return []
      }
    } // 数据
  },
  data () {
    return {}
  }
}
</script>

<style scoped>
.uni-steps {
  display: flex;
  width: 100%;
  flex: 1;
  flex-direction: column;
}

.uni-steps__row {
  display: flex;
  flex-direction: column;
}

.uni-steps__column {
  display: flex;
  flex-direction: row-reverse;
}

.uni-steps__row-text-container {
  display: flex;
  flex-direction: row;
}

.uni-steps__column-text-container {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.uni-steps__row-text {
  display: inline-flex;
  flex: 1;
  flex-direction: column;
}

.uni-steps__column-text {
  padding: 6px 0px;
  border-bottom-style: solid;
  border-bottom-width: 1px;
  border-bottom-color: #c8c7cc;
  display: flex;
  flex-direction: column;
}

.uni-steps__row-title {
  font-size: 16px;
  line-height: 16px;
  text-align: center;
}

.uni-steps__column-title {
  font-size: 16px;
  text-align: left;
  line-height: 18px;
}

.uni-steps__row-desc {
  font-size: 14px;
  line-height: 28px;
  text-align: center;
}

.uni-steps__column-desc {
  font-size: 14px;
  text-align: left;
  line-height: 18px;
}

.uni-steps__row-container {
  display: flex;
  flex-direction: row;
}

.uni-steps__column-container {
  display: inline-flex;
  width: 30px;
  flex-direction: column;
}

.uni-steps__row-line-item {
  display: inline-flex;
  flex-direction: row;
  flex: 1;
  height: 14px;
  line-height: 14px;
  align-items: center;
  justify-content: center;
}

.uni-steps__column-line-item {
  display: flex;
  flex-direction: column;
  flex: 1;
  align-items: center;
  justify-content: center;
}

.uni-steps__row-line {
  flex: 1;
  height: 4px;
}

.uni-steps__column-line {
  width: 1px;
  background-color: #999;
}

.uni-steps__column-line--after {
  flex: 1;
}

.uni-steps__column-line--before {
  height: 6px;
}

.uni-steps__row-circle {
  width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  border-radius: 100px;
  color: #fff;
  margin: 0px 5px;
  background-color: #e66465 !important;
}

.uni-steps__column-circle {
  width: 5px;
  height: 5px;
  border-radius: 100px;
  background-color: #999;
  margin: 4px 0px 5px 0px;
}

.uni-steps__row-check {
  margin: 0px 6px;
}

.uni-steps__column-check {
  height: 14px;
  line-height: 14px;
  margin: 2px 0px;
}
</style>
